package bdhub.littletail.app.process.push;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;

import bdhub.littletail.app.message.AppMessage;
import bdhub.littletail.lib.utils.log.CLog;

/**
 * Push服务
 * 注意：这里的代码是运行在push进程的，不要与主进程直接进行交互
 * Created by BDHub-7 on 2016/2/24.
 * chenshichao@outlook.com
 */
public class PushService extends Service {

    private static final String TAG = PushService.class.getSimpleName();

    @Override
    public void onCreate() {
        CLog.v(TAG, "onCreate()");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        CLog.v(TAG, "onStartCommand()");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public IBinder onBind(Intent intent) {
        CLog.v(TAG, "onBind()");
        return mBinder;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        CLog.v(TAG, "onUnbind()");
        return super.onUnbind(intent);
    }

    @Override
    public void onRebind(Intent intent) {
        CLog.v(TAG, "onRebind()");
        super.onRebind(intent);
    }

    private final IPushReceiver.Stub mBinder = new IPushReceiver.Stub() {
        @Override
        public int onSendMessage(AppMessage msg) throws RemoteException {
            CLog.d(TAG, "Current Process is " + android.os.Process.myPid());
            CLog.d(TAG, "PushService...onSendMessage()");
            return 0;
        }

        @Override
        public int updateState(int status) throws RemoteException {
            CLog.d(TAG, "PushService...updateState()");
            return 0;
        }

        @Override
        public void setDelayTime(long delayTime) throws RemoteException {
            CLog.d(TAG, "PushService...setDelayTime()");
        }

        @Override
        public void refreshImsAddress(String addrs) throws RemoteException {
            CLog.d(TAG, "PushService...refreshImsAddress()");
        }

        @Override
        public boolean isBoundToMainService() throws RemoteException {
            CLog.d(TAG, "PushService...isBoundToMainService()");
            return false;
        }
    };
}
